package com.baozhun.mall.common.bindadapter

import androidx.databinding.BindingAdapter
import androidx.recyclerview.widget.RecyclerView
import com.baozhun.mall.common.R
import com.blankj.utilcode.util.SizeUtils
import com.fondesa.recyclerviewdivider.dividerBuilder

/**
 * 作者　: hegaojian
 * 时间　: 2019/12/23
 * 描述　: 自定义 BindingAdapter
 */
object RecycleViewBindAdapter {

    @BindingAdapter(value = ["dividerHeight", "dividerColor"], requireAll = false)
    @JvmStatic
    fun setRecycleViewParams(recyclerView: RecyclerView, dividerHeight: Int, dividerColor: Int) {
        recyclerView.context?.dividerBuilder()
            ?.color(if (dividerColor == 0) recyclerView.context.getColor(com.baozhun.mall.res.R.color.trans_parent) else dividerColor)
            ?.size(SizeUtils.dp2px(dividerHeight.toFloat()))
            ?.build()
            ?.addTo(recyclerView)
    }

}